package com.finger.forest.dialog;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.PopupWindow;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;

import com.finger.forest.MeasurePointActivity;
import com.finger.forest.R;
import com.finger.forest.ToMapLocationActivity;
import com.finger.forest.base.SystemConfig;
import com.jakewharton.rxbinding2.view.RxView;

import java.util.concurrent.TimeUnit;

/**
 * @author sy
 * @date 2021/1/19
 * @desc
 */
public class NoticeItemDialog extends AlertDialog {

    private Context context;
    private TextView tvClose;
    private TextView tvLook;
    private TextView tvLocation;

    private View.OnClickListener onClickListener;

    public NoticeItemDialog(@NonNull Context context, int themeResId, View.OnClickListener onClickListener) {
        super(context, themeResId);
        this.context = context;
        this.onClickListener = onClickListener;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.notice_item_dialog_view);

        setCancelable(true);
        setCanceledOnTouchOutside(false);

        Window window = getWindow();
        WindowManager.LayoutParams wlp = window.getAttributes();
        wlp.width = WindowManager.LayoutParams.MATCH_PARENT;
        wlp.height = WindowManager.LayoutParams.MATCH_PARENT;
        window.setAttributes(wlp);

        tvClose = findViewById(R.id.tvClose);
        RxView.clicks(tvClose).throttleFirst(2, TimeUnit.SECONDS).subscribe(o -> {
            dismiss();
        });

        //查看视频
        tvLook = findViewById(R.id.tvLook);
        tvLook.setOnClickListener(onClickListener);

        tvLocation = findViewById(R.id.tvLocation);
        tvLocation.setOnClickListener(onClickListener);
    }
}
